package zb.blog.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import zb.blog.base.bean.Result;
import zb.blog.bean.CommentBean;
import zb.blog.service.ICommentService;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * @Author: BinZhang
 * @Date: 2018/5/1 15:23
 * @Description:评论相关
 */
@Controller
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private ICommentService iCommentService;

    /**
     * @Author: BinZhang
     * @Date: 2018/5/12 17:07
     * @Description:添加评论
     */
    @RequestMapping("/addComment")
    @ResponseBody
    public Result addComment(@RequestBody Map<String, String> param, HttpSession session) {
        return iCommentService.addComment(param, session);
    }

    /**
     * @Author: BinZhang
     * @Date: 2018/5/12 21:21
     * @Description:获取文章的评论列表
     */
    @RequestMapping("/getCommByArtId")
    @ResponseBody
    public Map<String, Object> getCommentByArticleId(int pageNum, String id, Integer type) {
        return iCommentService.getCommentByArticleId(pageNum, null, id, type);
    }
}
